<template>
  <div>
       <!-- <el-form  :inline="true"   size="mini">
        <div class="search-common">
        
             <el-form-item>
            <el-button type="primary">新增</el-button> 
          </el-form-item>
        </div>
        </el-form> -->
<div class="mt10 p10" style="background:#fff">
        <br>
  <el-table
  border
    :data="queryList"
    size="mini"
    :stripe="true"
    style="width:99%">
    <el-table-column
      prop="code"
      label="专业代码"
    >
    </el-table-column>
    <el-table-column
      prop="name"
      label="专业名称"
     >
    </el-table-column>
    <el-table-column
      label="经纪商"
      prop="agent_name"
     >
     
    </el-table-column>
    <el-table-column
      label="APP图标"
    >
        <template slot-scope="scope">
    <img  :src="scope.row.icon" width="30" height="30" />
    </template>
    </el-table-column>

  <el-table-column
      label="PC图标"
     >
      <template slot-scope="scope">
    <img  :src="scope.row.icon_pc" width="30" height="30" />
    </template>
    </el-table-column>

     <el-table-column
      prop="count_down"
      label="非时倒计时"
    >
    </el-table-column>
    <el-table-column
      label="状态"
    >
   <template slot-scope="scope">
    {{scope.row.status==0?'使用中':'未使用'}}
  </template>
    </el-table-column>
    <el-table-column
      label="操作"
      width="150">
      <template slot-scope="scope">
        <el-button type="text" size="small" @click="editPostion(scope.row)">编辑</el-button>
         <el-button type="text" size="small" @click="deletePostionItem(scope.row)">删除</el-button>
      </template>
    </el-table-column>
    </el-table>
  </div>
  <div class="block mt15">
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="page"
      :page-size="pageSize"
      layout="total, prev, pager, next"
      :total="total">
    </el-pagination>
  </div>



  <add-diglog :title="title" :edit-data="editDialog" :role-dialog="postionDialog" @addAndClick="addAndEditMenu" @cancelAndClick="cancelDialog"></add-diglog>


  </div>
</template>
<script>
import addDiglog from "./add";
import service from "@/service/index_c";
export default {
  data() {
    return {
      page: 1,
      pageSize: 10,
      total: 0,
      queryList: [],
      editDialog: {},
      postionDialog: false,
      title: "编辑"
    };
  },
  mounted() {
    this.queryPostionList();
  },
  methods: {
    handleCurrentChange(page) {
      this.queryPostionList(page);
    },
    //查询列表
    async queryPostionList(page = 1) {
      let res = await service.haiheiServerPostionList({
        page: page,
        pageSize: this.pageSize
      });
      if (res.success) {
        this.queryList = res.result.pageList;
        this.page = res.result.page;
        this.total = res.result.nums;
      }
    },
    deletePostionItem(item) {
      this.$confirm("您确定要删除该条数据吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        lockScroll: false
      })
        .then(() => {
          service.haiheiServerDeletePostion({ id: item.id }).then(res => {
            if (res.success) {
              this.$message({
                type: "success",
                message: res.msg
              });
              this.queryPostionList();
            } else {
              this.$message({
                type: "error",
                message: res.msg
              });
            }
          });
        })
        .catch(() => {});
    },
    editPostion(item) {
      item.count_down = item.count_down + "";
      this.editDialog = item;
      this.postionDialog = true;
    },
    async addAndEditMenu(params) {
      console.log(params);
      // return ;
      let res = await service.haiheiServerEditPostion(params);
      if (res.success) {
        this.queryPostionList();
        this.postionDialog = false;
      }
    },
    cancelDialog(bool) {
      this.postionDialog = bool;
    }
  },
  components: {
    addDiglog
  }
};
</script>

